﻿using System;
using System.Collections.Generic;
using System.Linq.Expressions;

namespace SecureBox.UI.Infrastructure.Model
{
    /// <summary>
    /// A simply repository which incapsulates the implementation of data layer
    /// </summary>
    /// <typeparam name="T"></typeparam>
    public interface IRepository<T>
    {
        /// <summary>
        /// Add entity to repository
        /// </summary>
        /// <param name="entity"></param>
        void Add(T entity);

        /// <summary>
        /// Gets entity using predicate provided
        /// </summary>
        /// <param name="predicate"></param>
        /// <returns></returns>
        T Get(Expression<Func<T, bool>> predicate);

        /// <summary>
        /// Updates entity in repository
        /// </summary>
        /// <param name="entity"></param>
        void Update(T entity);

        /// <summary>
        /// Removes entites from repository using predicate provided
        /// </summary>
        /// <param name="predicate"></param>
        void Remove(Expression<Func<T, bool>> predicate);

        /// <summary>
        /// Returns all entities from repository
        /// </summary>
        /// <returns></returns>
        IEnumerable<T> List();

        /// <summary>
        /// Returns entitites using predicate provided
        /// </summary>
        /// <param name="predicate"></param>
        /// <returns></returns>
        IEnumerable<T> List(Expression<Func<T, bool>> predicate);

        /// <summary>
        /// Commit changes
        /// </summary>
        void Commit();
    }
}
